package com.coo1.onlineorder.server;

import java.io.IOException;
import java.text.ParseException;
import java.util.ArrayList;
import java.util.Date;
import java.util.Hashtable;
import java.util.List;

import javax.jdo.PersistenceManager;
import javax.jdo.Query;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.coo1.onlineorder.server.data.MSTADMIN;
import com.coo1.onlineorder.server.data.MSTUSER;
import com.coo1.onlineorder.server.dataStore;

public class TestCreateUserServlet extends HttpServlet implements java.io.Serializable {
    /**
	 * 
	 */
	private static final long serialVersionUID = 1L;
    @SuppressWarnings({ "unchecked", "deprecation" })
	public void doPost(HttpServletRequest req, HttpServletResponse resp)
    throws IOException {

    	Date birthdayd = null;
		String userid = req.getParameter("userID");
		String password = req.getParameter("passwd");
		String username = req.getParameter("username");
		String realname = req.getParameter("realname");
		String address = req.getParameter("address");
		String mail = req.getParameter("mail");
		String phone = req.getParameter("phone");
		
		String sex = req.getParameter("male");
		String birthday = req.getParameter("birthday");
		   java.text.DateFormat df2 = new java.text.SimpleDateFormat("yyyyMMdd");
		   try {
		    birthdayd = df2.parse(birthday);
		   } catch (ParseException e) {

		   }
		if (username == null) {
			username = "(No username)";
		}
		
        PersistenceManager pm = PMF.get().getPersistenceManager();

        MSTUSER m = new MSTUSER(username, realname,password, 
        		new Date(), birthdayd, true, null, address, mail, phone, null,birthdayd);

        try {
            pm.makePersistent(m);
        } finally {
            pm.close();
        }
		resp.sendRedirect("/TestMailSending.jsp");
			       

}

	
	
}